
	** Uganda
	** Clean wave 7
		
	** Urban status
	
		use "$dir/rawdata/LSMS Uganda/2019/HH/gsec1.dta", clear
		gen w7_urban=urban==1
		
		keep hhid w7_*
		
		compress hhid
		
		tempfile urban
		save `urban', replace
		
	** Roster
		use "$dir/rawdata/LSMS Uganda/2019/HH/gsec2.dta", clear
		
		gen w7_female=h2q3==2 if !missing(h2q3)
		gen w7_age=h2q8
		gen w7_married=(h2q10==1 | h2q10==2) if !missing(h2q10)
		
		gen w7_inhh=h2q7<=4
		
		bys hhid: egen w7_hh_size=total(w7_inhh)
		ren pid indiv
		
		keep hhid indiv w7_*
		tempfile roster
		save `roster', replace
		
	** Illness or injury
	
		use "$dir/rawdata/LSMS Uganda/2019/HH/gsec5.dta", clear
	
		gen w7_illinj=s5q04==1 if !missing(s5q04)
		gen w7_illinjstopactivities=s5q06>0 if !missing(s5q06)
		replace w7_illinjstopactivities=0 if w7_illinj==0
		
		ren pid indiv 
		
		compress hhid
		
		keep hhid indiv w7_*		
		tempfile illinj
		save `illinj', replace
		
	** Employment 
		
		use "$dir/rawdata/LSMS Uganda/2019/HH/gsec8.dta", clear
		
		gen w7_work_outsideHH=s8q04==1 if !missing(s8q04)
		
		gen w7_work_bizHH=(s8q06==1 | s8q08==1) if (!missing(s8q06) | !missing(s8q08))
		
		gen w7_work_agHH=(s8q12==1) if !missing(s8q12)
		
		egen w7_worked_last7days=rowmax(w7_work_outsideHH w7_work_agHH w7_work_bizHH)
		
		egen w7_work_hrs=rowtotal(s8q36a s8q36b s8q36c s8q36d s8q36e s8q36f s8q36g s8q43a s8q43b s8q43c s8q43d s8q43e s8q43f s8q43g), mi // inludes working on a household business, agriculture, etc.
		
		ren pid indiv
		keep hhid indiv w7_*
		
		compress hhid
		
		tempfile employment
		save `employment', replace

	** Disabilities
	
		*n/a
		
	** Merge and save
	
		use `roster', clear
		compress
		merge 1:1 hhid indiv using `illinj', gen(merge_illinj)
		merge 1:1 hhid indiv using `employment', gen(merge_employment)
		merge m:1 hhid using `urban', gen(merge_urban)
		
		save "$dir/data/uga_w7_individual.dta", replace
